package com.mes.defece.controller;

import com.mes.common.pojo.MESResult;
import com.mes.defece.service.IncomingService;
import com.mes.pojo.defece.Incoming;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 侯伟豪
 * @Company 起点编程
 * @Description
 * @Time 2024/10/22 14:43
 */
@RestController
@CrossOrigin
@RequestMapping("/incoming")
public class IncomingController {
    @Autowired
    private IncomingService incomingService;
//    分页查询
    @GetMapping("/selectAll")
    public MESResult selectAll(Incoming incoming, @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "20") Integer limit)
    {
        System.out.println(incoming);
        return incomingService.selectAll(incoming,page,limit);
    }
//    新增来料检验单信息
    @PostMapping("/add")
    public MESResult addIncoming(@RequestBody Incoming incoming)
    {
        return incomingService.addIncoming(incoming);
    }
//    根据id查询检验单数据
    @GetMapping("/selectById")
    public MESResult selectById(Long incomingId)
    {
        return incomingService.selectById(incomingId);
    }
//    根据id修改检验单数据
    @PutMapping("/update")
    public MESResult updateById( @RequestBody Incoming incoming)
    {
        return incomingService.updateIncomingById(incoming);
    }
//    导出数据
@GetMapping("/export")
public MESResult export(Incoming incoming, @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "20") Integer limit)
{
    return incomingService.getExport(incoming, page, limit);
}
//删除数据
    @DeleteMapping("/delete")
    public MESResult deleteById(Long incomingId)
    {
        return incomingService.deleteById(incomingId);
    }
}